#ifndef NMARRFIELD_H_
#define NMARRFIELD_H_

#include "rectype.h"
#include <vector>
#include <string>


using namespace std;

namespace opsrc {
	namespace stdf {

	
	
	//	template <typename T, int L, template <typename> class CONT = std::vector >
	template <typename T, int L, template <typename A, typename = std::allocator<A> > 
	class CONT=std::vector > 
	class NmArrField {
		public:
			NmArrField();
			NmArrField(char *p, endian e, int elcount);
			virtual ~NmArrField();

			void decode(char* buf, int elemcount);
			int getByteCount() const; 
			const CONT<T> getData() const;	
			string arrayToString();
			
			int getCount() const;	
			
			int getTotalByteCount() const;					
			
		private:
			CONT<T> cont;
			int len;
			endian en;	
		};

		// Specialization for float type, 
		template <int L, template <typename A, typename = std::allocator<A> > class CONT >
		class NmArrField<float,L,CONT> {
		public:
			NmArrField();
			NmArrField(char *p, endian e, int elcount);
			virtual ~NmArrField();

			void decode(char* buf, int elemcount);
			int getByteCount() const; 
			const CONT<float> getData() const;
			string arrayToString();
			
			int getCount() const;						
			int getTotalByteCount() const;					

		private:
			CONT<float> cont;
			int len;
			endian en;	
		};
		

		// Specialization for bool type, which is reading from bits. 
		//This correspond to Dn datatype
		template <int L, template <typename A, typename = std::allocator<A> > class CONT >
		class NmArrField<bool,L,CONT> {
		public:
			NmArrField();
			NmArrField(char *p, endian e, int elcount);
			virtual ~NmArrField();

			void decode(char* buf, int elemcount);
			int getByteCount() const; 
			const CONT<bool> getData() const;	
			string arrayToString();
			
			int getCount() const;						
			int getTotalByteCount() const;					

			string at(int pos);
		private:
			CONT<bool> cont;
			int len;
			endian en;	
		};
		
		
		// Specialization for Nibble
		template <int L, template <typename A, typename = std::allocator<A> > class CONT >
		class NmArrField<Nibble,L,CONT> {
		public:
			NmArrField();
			NmArrField(char *p, endian e, int elcount);
			virtual ~NmArrField();

			void decode(char* buf, int elemcount);
			int getByteCount() const; 
			const CONT<int> getData() const;	
			string arrayToString();
			
			int getCount() const;						
			int getTotalByteCount() const;					
			
		private:
			CONT<int> cont;
			int len;
			endian en;	
		};		
		
		

	}	// namespace stdf
}		// namespace opsrc

#endif /*NMARRFIELD_H_*/
